package adapter

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/pay-channel-packet/hkppay"
	"gitee.com/liuxuezhan/ar-platform/pay-channel-packet/payClient/dto"
	"gitee.com/liuxuezhan/ar-platform/pay-channel-packet/payClient/interfaceP"
)

type HkpAdapter struct {
	merchantId string
}

func NewHkpAdapter(opt ...interfaceP.Option) *HkpAdapter {
	res := &HkpAdapter{}
	res.WithOption(opt...)
	return res
}

func (da *HkpAdapter) AdapterPay(ctx context.Context, req dto.PayRequestDto) (dto.PayResponseDto, error) {
	return hkppay.NewHkp().Payin(ctx, req)
}

func (da *HkpAdapter) AdapterPayNotify(req dto.PayNotifyReqDto) (dto.PayNotifyRespDto, error) {
	return hkppay.NewHkp().PayinNotify(req)
}

func (da *HkpAdapter) AdapterWithdraw(ctx context.Context, req dto.WithdrawRequestDto) (dto.WithdrawResponseDto, error) {
	return hkppay.NewHkp().Payout(ctx, req)
}

func (da *HkpAdapter) AdapterWithdrawNotify(req dto.WithdrawNotifyReqDto) (dto.WithdrawNotifyRespDto, error) {
	return hkppay.NewHkp().PayoutNotify(req)
}

func (da *HkpAdapter) WithOption(opt ...interfaceP.Option) {
	for _, i := range opt {
		i(da)
	}
}

var _ interfaceP.AdapterInterface = (*HkpAdapter)(nil)
